<template>
  <div >
    <top @listeEVent="listeEVent"/>
    <div class="listmain">
      <div class="sea-data">
        <span>共计100条结果</span>
        <span>筛选</span>
      </div>
      <div v-if="hid" class="no-data">
        <img src="@/assets/home/no_data.png" alt="">
        <span>暂无数据...<i class="el-icon-loading"/></span>
      </div>
      <div class="list">
        <div v-for="(item, idx) in dataAll" :key="idx" class="list-child">
          <h4>{{ item.title }}</h4>
          <blockquote>{{ item.stu_con }}</blockquote>
          <div class="list-bot">
            <div class="head-img">
              <img src alt>
            </div>
            <div class="list-info">
              <a href>
                <span>{{ item.stu_name }}</span>
              </a>
              <span>{{ item.stu_time }}</span>
            </div>
            <div class="ask-num">
              <i class="el-icon-tickets"/>
              <span>7个回答</span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { findCon } from '@/api/ask'
import top from '../home/top.vue'
export default {
  name: 'SeachList',
  components: {
    top
  },
  data() {
    return {
      findVal: '',
      dataAll: [],
      hid: 0
    }
  },
  watch: {
    findVal: function(val) {
      const that = this
      const obj = {}
      obj.search = val
      console.log(obj)
      findCon(obj).then(response => {
        that.dataAll = response.data
        if (response.data === null || response.data === '') {
          that.hid = 1
        } else {
          that.hid = 0
        }
      })
    }
  },
  methods: {
    listeEVent(init) {
      this.findVal = init
    }
  }
}
</script>
<style lang="scss" scoped>
.listmain {
  font-size: 14px;
  .sea-data {
    margin-top: 20px;
  }
  .no-data {
    width: 160px;
    height: 160px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    text-align: center;
    font-size: 18px;
    color: #353535;
  }
  .list {
    width: 800px;
    height: auto;
    margin-top: 20px;
    .list-child {
      width: 100%;
      min-height: 200px;
      padding: 20px;
      border-radius: 3px;
      border: 1px solid #f0f0f0;
      margin-bottom: 20px;
      background: #fff;
      h4 {
        font-size: 18px;
      }
      blockquote {
        display: block;
        margin-block-start: 1em;
        margin-block-end: 1em;
        margin-inline-start: 2px;
        margin-inline-end: 40px;
        color: #636363;
        line-height: 24px;
      }
      .list-bot {
        margin-top: 40px;
        line-height: 30px;
        position: relative;
        .head-img {
          width: 30px;
          height: 30px;
          border-radius: 15px;
          background: #636363;
          float: left;
          img {
            width: 100%;
          }
        }
        .list-info {
          float: left;
          margin-left: 10px;
          span:nth-child(1) {
            font-size: 9px;
            font-family: arial;
            cursor: pointer;
          }
          span:nth-child(2) {
            font-size: 9px;
            font-family: arial;
            color: #959595;
          }
        }
        .ask-num {
          float: right;
          color: #959595;
        }
      }
    }
  }
}
</style>
